function AppUser(obj) {
    this.companyId = obj.companyId;
    this.companyName = obj.companyName;
    this.email = obj.email;
    this.fullName = obj.fullName;
    this.headImg = obj.headImg;
    this.id = obj.id;
    this.mobileNumber = obj.mobileNumber;
    this.registerDate = obj.registerDate;
    this.userRole = obj.userRole;
}

function password() {
    openWebview("my-password");
}

function onPageReady() {
    try {
        $('.header').css('margin-top', plus.navigator.getStatusbarHeight() * 2 + 'px');
    } catch (e) {
    }
    reload();
}

function reload() {
    var info = getLocalItem("user");
    if (info) {
        info = new AppUserBean(info);
        ajax({
            url: "/api/user/query",
            type: "post",
            dataType: "json",
            headers: {},
            data: {},
            success: function (result) {
                var item = new AppUser(result.data), user = getLocalItem('user');
                user.companyId = item.companyId;
                user.companyName = item.companyName;
                user.email = item.email;
                user.fullName = item.fullName;
                user.headImg = item.headImg;
                user.id = item.id;
                user.mobileNumber = item.mobileNumber;
                user.registerDate = item.registerDate;
                user.userRole = item.userRole;
                setLocalItem('user', user);
                item.headImg = item.headImg || '../../../img/head.svg';
                $(".info").render("#info", item, "html");
            }
        });
        $(".exit").css("display", "flex");
        $(".password+.line").show();
        $(".password").css("display", "flex");
    } else {
        $(".info").render("#login", {headImg: base_path + "img/head.svg", fullName: "点击登录"}, "html");
    }
}